import time

from selenium.webdriver.support.select import Select

from public.action import *
from public.business import *
from public.testData import *
from public.tools import *
testCase="DBshop034_余额调整流程"

# 1.登录后台
firefox=openBrowser(urlAdmin) #调用自定义函数打开网页
DBshopLoginAdmin(firefox)  # 调用自定义函数进行后台的登录
# 2.进入前台侧边显示设置
DBshopEnterMenu2(firefox,'客户管理','管理客户')

# 3.点击“余额调整”按钮。
t1=(firefox.find_element_by_xpath("//td[contains(.,'dxd')]/following-sibling::td[5]").text) #获取客户dxd添加前客户余额
t4=int(float(t1))
print(t4)
firefox.find_element_by_xpath("//td[contains(.,'dxd')]/following-sibling::td[7]/a[2]").click()
# 4.客户dxd,金额增加"10000",备注内容“买手机用”
s=Select(firefox.find_element_by_id("money_change_type_1"))
s.select_by_visible_text('增加')
firefox.find_element_by_id("money_change_num").send_keys("10000")
firefox.find_element_by_id("money_pay_info").send_keys("买手机用")
# 5.点击“提交充值”按钮。在前台查询cyy是否余额多10000.
firefox.find_element_by_xpath("//button[contains(.,'提交充值')]").click()
time.sleep(3)

# 断言
t2=(firefox.find_element_by_xpath("//td[contains(.,'dxd')]/following-sibling::td[5]").text)
t3=int(float(t2))
print(t3)
if t3-10000==t4:
    writeLog("%s 测试通过"%testCase)
else:
    writeLog("%s 测试失败" % testCase)
    getPhoto(firefox)
time.sleep(3)
firefox.quit() #quit()函数有2个作用 1.关闭所有页面 2.关闭浏览器对象 quit()函数建议放到脚本的最后



